<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="posts"></div>
    <script>
        // 前端 通过fetch 去和后端通信
        // 前端取数据的API
        fetch('http://localhost:3000/posts')// 连接后端资源 
        .then(data=>data.json())
        .then(data=>{
            document.getElementById('posts').innerHTML=data.map(post=>`
            <li>
                ${post.id} ${post.title} ${post.author}
                </li>
                `).join('')
            console.log(data);
        })

    </script>

</body>
</html>